package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {
	// 1. mutiplication
	for row := 1; row <= 9; row++ {
		for column := 1; column <= 9; column++ {
			if column <= row {
				fmt.Printf("%d*%d=%d\t", column, row, column*row)
			} else {
				fmt.Println()
				break
			}

		}
	}
	fmt.Println()

	// 2. print 20 random values randomly and calculate
	oddIndex, evenNumber := 0, 1
	for i := 1; i <= 20; i++ {
		time.Sleep(1 * time.Microsecond)
		rand.Seed(time.Now().UnixNano())
		randNumber := rand.Intn(21-1) + 1
		// 偶数进行相乘计算
		if i%2 == 0 {
			evenNumber = evenNumber * randNumber
		} else {
			oddIndex = oddIndex + randNumber
		}
	}
	fmt.Printf("所有奇数位置的数字相加之和为%d, 所有偶数位置相乘只积为%d\n", oddIndex, evenNumber)

	// 3. calculate fibonacci list within 100
	fiboSlice := []int{1, 1}
	a, b := 1, 1
	for c := 0; true; {
		c = a + b
		if c > 100 {
			break
		}
		fiboSlice = append(fiboSlice, c)
		a = b
		b = c
	}
	fmt.Println(fiboSlice)

}

// 阿飞老师的批改
// 实现的逻辑非常清晰，适当写一些注释方便以后自己查看
